# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Guillaume Alaux <guillaume@archlinux.org>
# Contributor: Vitaliy Berdinskikh <ur6lad@i.ua>

pkgname=tomcat-native
pkgver=2.0.3
pkgrel=1
pkgdesc='Optional component for Tomcat to use certain native resources for performance, compatibility'
arch=(x86_64)
url=https://tomcat.apache.org/native-doc/
license=(APACHE)
depends=(
  apr
  openssl
)
makedepends=(
  git
  java-environment
  python
)
options=(!emptydirs)
_tag=2b617703217b2f94fc51afc0ad30e325f69853a2
source=(
  git+https://github.com/apache/tomcat-native.git#tag=${_tag}
  tomcat-native-buildconf.patch
)
b2sums=(
  SKIP
  d3603079626b908644331c193452088ef3ce89e92c775c60b232d16d04b8c49d40106d55c76f81c87daea93d335868140df0046c7102796d92b08431ac8749a4
)

pkgver() {
  cd tomcat-native
  git describe --tags
}

prepare() {
  cd tomcat-native/native
  patch -Np2 -i ../../tomcat-native-buildconf.patch
  automake --add-missing --copy --force-missing || true
  ./buildconf \
    --with-apr=/usr/share/apr-1
}

build() {
  cd tomcat-native/native
  ./configure \
    --prefix=/usr \
    --with-apr=/usr/bin/apr-1-config \
    --with-java-home=/usr/lib/jvm/default \
    --with-ssl=/usr
  make
}

package() {
  make DESTDIR="${pkgdir}" -C tomcat-native/native install
}

# vim: ts=2 sw=2 et:
